﻿
namespace ZR.Model.Models.ProductionControl
{
    /// <summary>
    /// 记录工件加工过程的详细信息
    /// </summary>
    [SugarTable("cks_production_record")]
    [Table(Name = "cks_production_record")]
    public class CksProductionRecord : BaseEntity
    {
        /// <summary>
        /// Id 
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        [Column(IsPrimary = true, IsIdentity = true)]
        [ExcelIgnore]
        public long Id { get; set; }

        /// <summary>
        /// 加工流水号 
        /// </summary>
        public string SerialNumber { get; set; } = string.Empty;

        /// <summary>
        /// 盖板码 
        /// </summary>
        public string CoverCode { get; set; } = string.Empty;

        /// <summary>
        /// 成品码 
        /// </summary>
        public string ProductCode { get; set; } = string.Empty;

        /// <summary>
        /// 条码等级 
        /// </summary>
        public string BarcodeGrade { get; set; } = string.Empty;

        /// <summary>
        /// 加工状态 
        /// 1：A面投入；2：A面开始；3：A面结束；4:A面取出
        /// 5：打标投入；6：打标开始；7：打码完成；8：打标评级
        /// 9：B面投入；10：B面开始；11：B面结束；12:B面取出
        /// 100:完成
        /// </summary>
        [ExcelIgnore]
        public int ProcessingStatus { get; set; }

        [SugarColumn(IsIgnore = true)]
        [Column(IsIgnore = true)]
        public string ProcessingStatusText 
        {
            get
            {
                Dictionary<int,string> dic = new Dictionary<int,string>();
                dic.Add(1, "A面投入");
                dic.Add(2, "A面开始");
                dic.Add(3, "A面结束");
                dic.Add(4, "A面取出");
                dic.Add(5, "打标投入");
                dic.Add(6, "打标开始");
                dic.Add(7, "打标完成");
                dic.Add(8, "打标评级");
                dic.Add(9, "B面投入");
                dic.Add(10, "B面开始");
                dic.Add(11, "B面结束");
                dic.Add(12, "B面取出");
                dic.Add(100, "完成");
                if(dic.ContainsKey(ProcessingStatus))
                    return dic[ProcessingStatus];
                else
                    return string.Empty;
            }
        }

        /// <summary>
        /// PLC上传状态，每个站的状态分为 1 投入 2开始 3结束 4取出 
        /// </summary>
        [ExcelIgnore]
        [SugarColumn(IsIgnore =true)]
        [Column(IsIgnore =true)]
        public int UploadStatus {  get; set; }

        /// <summary>
        /// A面的机床编号 
        /// </summary>
        public int ASideMachineNumber { get; set; }

        /// <summary>
        /// A面的工装编号 
        /// </summary>
        public int ASideToolingNumber { get; set; }

        /// <summary>
        /// A面投入时间 
        /// </summary>
        public DateTime? ASideLoadingTime { get; set; }

        /// <summary>
        /// A面开始时间 
        /// </summary>
        public DateTime? ASideStartTime { get; set; }

        /// <summary>
        /// A面结束时间 
        /// </summary>
        public DateTime? ASideEndTime { get; set; }

        /// <summary>
        /// A面取出时间 
        /// </summary>
        public DateTime? ASideUnloadingTime { get; set; }

        /// <summary>
        /// 打标清洗投入时间 
        /// </summary>
        public DateTime? MarkingLoadingTime { get; set; }

        /// <summary>
        /// 打标开始时间 
        /// </summary>
        public DateTime? MarkingStartTime { get; set; }

        /// <summary>
        /// 打码并完成评级的时间 
        /// </summary>
        public DateTime? MarkingCompletedTime { get; set; }

        /// <summary>
        /// 打标取出时间 
        /// </summary>
        public DateTime? MarkingGradingTime { get; set; }

        /// <summary>
        /// B面的机床编号 
        /// </summary>
        public int BSideMachineNumber { get; set; }

        /// <summary>
        /// B面的工装编号 
        /// </summary>
        public int BSideToolingNumber { get; set; }

        /// <summary>
        /// B面投入时间 
        /// </summary>
        public DateTime? BSideLoadingTime { get; set; }

        /// <summary>
        /// B面开始时间 
        /// </summary>
        public DateTime? BSideStartTime { get; set; }

        /// <summary>
        /// B面完成时间 
        /// </summary>
        public DateTime? BSideEndTime { get; set; }

        /// <summary>
        /// B面取出的时间 
        /// </summary>
        public DateTime? BSideUnloadingTime { get; set; }

  
        /// <summary>
        /// Nullity 
        /// </summary>
        [ExcelIgnore]
        public bool Nullity { get; set; }

        /// <summary>
        /// CreatedTime 
        /// </summary>
        [ExcelIgnore]
        public DateTime CreatedTime { get; set; } = DateTime.Now;



    }
}